using System;
using System.Collections;
using System.Collections.Specialized;
using System.Data;
using System.Data.SqlTypes;
using System.Data.SqlClient;
using System.Text;
using ECommerce.DAL;


namespace Entity
{
	/// <summary>
	/// This object represents the Private Fields of TblProductPurchaseOrderMultiple.
	/// </summary>
	
	[System.ComponentModel.DataObject]
    public class TblProductPurchaseOrderMultiple : DatabaseUtility
    {
		#region TblProductPurchaseOrderMultiple Private Fields


		Int32 _multipleId;
		Int32 _orderId;
		Int32 _productId;
		Int32 _quantity;
		String _shippingFirstName = String.Empty;
		String _shippingLastName = String.Empty;
		String _shippingAddressLine1 = String.Empty;
		String _shippingAddressLine2 = String.Empty;
		String _shippingCity = String.Empty;
		String _shippingAddressState = String.Empty;
		String _shippingAddressCountry = String.Empty;
		String _shippingZipCode = String.Empty;
		String _shippingTelephoneNumber = String.Empty;
		String _shippingTelephoneNumber2 = String.Empty;
		String _shippingEmailAddress = String.Empty;
		
		#endregion
		#region TblProductPurchaseOrderMultiple Constractor
		/// <summary>
        /// Creates an empty object of TblProductPurchaseOrderMultiple. 
        /// This is mainly used to create a new instance of TblProductPurchaseOrderMultiple to add a new TblProductPurchaseOrderMultiple.
        /// </summary>
		public TblProductPurchaseOrderMultiple(){}
		
				
		/// <summary>
        /// Used to retrieve employee information from database, 
        /// which is also used by Update method to save information of an existing TblProductPurchaseOrderMultiple.
        /// </summary>
		public TblProductPurchaseOrderMultiple
		(
			Int32 multipleId,
			Int32 orderId,
			Int32 productId,
			Int32 quantity,
			String shippingFirstName,
			String shippingLastName,
			String shippingAddressLine1,
			String shippingAddressLine2,
			String shippingCity,
			String shippingAddressState,
			String shippingAddressCountry,
			String shippingZipCode,
			String shippingTelephoneNumber,
			String shippingTelephoneNumber2,
			String shippingEmailAddress
		)
		{
			_multipleId = multipleId;	
			_orderId = orderId;	
			_productId = productId;	
			_quantity = quantity;	
			_shippingFirstName = shippingFirstName;	
			_shippingLastName = shippingLastName;	
			_shippingAddressLine1 = shippingAddressLine1;	
			_shippingAddressLine2 = shippingAddressLine2;	
			_shippingCity = shippingCity;	
			_shippingAddressState = shippingAddressState;	
			_shippingAddressCountry = shippingAddressCountry;	
			_shippingZipCode = shippingZipCode;	
			_shippingTelephoneNumber = shippingTelephoneNumber;	
			_shippingTelephoneNumber2 = shippingTelephoneNumber2;	
			_shippingEmailAddress = shippingEmailAddress;	
		}
		
		#endregion
		#region TblProductPurchaseOrderMultiple Properties
		
		 /***********************************************************************************************
                                    -- PROPERTIES --        
         Contains all the properties representing the data fields of the current entity.
         ***********************************************************************************************/

        /// <summary>
        /// This is the Primary key value of the MultipleId, which can't be assigned from the application,
        /// to ensure the data consistancy, by not letting the user to change the PK_TblProductPurchaseOrderMultiple to update the data of an another TblProductPurchaseOrderMultiple instance.
        /// For view or updation purpose, every TblProductPurchaseOrderMultiple will be retrieved thru the proper 'Get' method.
        /// </summary>
		
		public Int32 MultipleId
		{
			get {return _multipleId;}	
		}
		
				
		public Int32 OrderId
		{
			get {return _orderId;}
			set {_orderId = value;}
		}

		public Int32 ProductId
		{
			get {return _productId;}
			set {_productId = value;}
		}

		public Int32 Quantity
		{
			get {return _quantity;}
			set {_quantity = value;}
		}

		public String ShippingFirstName
		{
			get {return _shippingFirstName;}
			set {_shippingFirstName = value;}
		}

		public String ShippingLastName
		{
			get {return _shippingLastName;}
			set {_shippingLastName = value;}
		}

		public String ShippingAddressLine1
		{
			get {return _shippingAddressLine1;}
			set {_shippingAddressLine1 = value;}
		}

		public String ShippingAddressLine2
		{
			get {return _shippingAddressLine2;}
			set {_shippingAddressLine2 = value;}
		}

		public String ShippingCity
		{
			get {return _shippingCity;}
			set {_shippingCity = value;}
		}

		public String ShippingAddressState
		{
			get {return _shippingAddressState;}
			set {_shippingAddressState = value;}
		}

		public String ShippingAddressCountry
		{
			get {return _shippingAddressCountry;}
			set {_shippingAddressCountry = value;}
		}

		public String ShippingZipCode
		{
			get {return _shippingZipCode;}
			set {_shippingZipCode = value;}
		}

		public String ShippingTelephoneNumber
		{
			get {return _shippingTelephoneNumber;}
			set {_shippingTelephoneNumber = value;}
		}

		public String ShippingTelephoneNumber2
		{
			get {return _shippingTelephoneNumber2;}
			set {_shippingTelephoneNumber2 = value;}
		}

		public String ShippingEmailAddress
		{
			get {return _shippingEmailAddress;}
			set {_shippingEmailAddress = value;}
		}
		

		#endregion
		#region TblProductPurchaseOrderMultiple Static Methods
		/************************************************************************************
                                    -- CREATE METHOD (STATIC) --
        *************************************************************************************/
		/************************* Architecure note:**********************************
        Note 1:
        This method is specially useful for the case, where we need to use Object Data Source controls.
        For ObjectDataSource/SqlDataSource controls, the insert/update metnod requires paramters methods, rather property based methods.
        However, there is still a way to pass property based objects as method parameter for data source controls, 
        but in that case we could not use Sql type, as view controls or asp parameter control can only contain few of primitive type.
        The main reason to remain the Sql Type in our object architecture is it is faster and contains better way for null value support.
        
        Note 2: 
        Non-primary key: it should be primitive type, as the asp paramter control (included in data source control) supports only primitive types.
        /*****************************************************************************/
		[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Insert, true)]
        public static  Int32 CreateNewTblProductPurchaseOrderMultiple
		(
			Int32 orderId,
			Int32 productId,
			Int32 quantity,
			String shippingFirstName,
			String shippingLastName,
			String shippingAddressLine1,
			String shippingAddressLine2,
			String shippingCity,
			String shippingAddressState,
			String shippingAddressCountry,
			String shippingZipCode,
			String shippingTelephoneNumber,
			String shippingTelephoneNumber2,
			String shippingEmailAddress
		)
		{
			//creating an empty TblProductPurchaseOrderMultiple object
            TblProductPurchaseOrderMultiple tblProductPurchaseOrderMultiple = new TblProductPurchaseOrderMultiple();
				tblProductPurchaseOrderMultiple.OrderId = orderId;
				tblProductPurchaseOrderMultiple.ProductId = productId;
				tblProductPurchaseOrderMultiple.Quantity = quantity;
				tblProductPurchaseOrderMultiple.ShippingFirstName = shippingFirstName;
				tblProductPurchaseOrderMultiple.ShippingLastName = shippingLastName;
				tblProductPurchaseOrderMultiple.ShippingAddressLine1 = shippingAddressLine1;
				tblProductPurchaseOrderMultiple.ShippingAddressLine2 = shippingAddressLine2;
				tblProductPurchaseOrderMultiple.ShippingCity = shippingCity;
				tblProductPurchaseOrderMultiple.ShippingAddressState = shippingAddressState;
				tblProductPurchaseOrderMultiple.ShippingAddressCountry = shippingAddressCountry;
				tblProductPurchaseOrderMultiple.ShippingZipCode = shippingZipCode;
				tblProductPurchaseOrderMultiple.ShippingTelephoneNumber = shippingTelephoneNumber;
				tblProductPurchaseOrderMultiple.ShippingTelephoneNumber2 = shippingTelephoneNumber2;
				tblProductPurchaseOrderMultiple.ShippingEmailAddress = shippingEmailAddress;
			
			return TblProductPurchaseOrderMultiple.CreateNewTblProductPurchaseOrderMultiple(tblProductPurchaseOrderMultiple);
		}
	
		/************************************************************************************
                 -- UPDATE METHODS (STATIC) --
        *************************************************************************************/

        /************************* Architecure note:**********************************
        Note 1:
        This method is specially useful for the case, where we need to use Object Data Source controls.
        For ObjectDataSource/SqlDataSource controls, the insert/update metnod requires paramters methods, rather property based methods.
        However, there is still a way to pass property based objects as method parameter for data source controls, 
        but in that case we could not use Sql type, as view controls or asp parameter control can only contain few of primitive type.
        The main reason to remain the Sql Type in our object architecture is it is faster and contains better way for null value support.
        
        Note 2: 
        There the two types of paramaters will be passed here.
         * a. Primary key paramater: it should be Sql type, as we will bind the primary key property for the view controls (form view, details view etc) as datakey.
         * b. Non-primary key: it should be primitive type, as the asp paramter control (included in data source control) supports only primitive types.
        /*****************************************************************************/
		
		[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Update, true)]
        public static  bool UpdateTblProductPurchaseOrderMultiple
		(
			Int32 multipleId,
			Int32 orderId,
			Int32 productId,
			Int32 quantity,
			String shippingFirstName,
			String shippingLastName,
			String shippingAddressLine1,
			String shippingAddressLine2,
			String shippingCity,
			String shippingAddressState,
			String shippingAddressCountry,
			String shippingZipCode,
			String shippingTelephoneNumber,
			String shippingTelephoneNumber2,
			String shippingEmailAddress
		)
		{
			 TblProductPurchaseOrderMultiple tblProductPurchaseOrderMultiple =  TblProductPurchaseOrderMultiple.GetTblProductPurchaseOrderMultipleByMultipleId(multipleId);
			
				tblProductPurchaseOrderMultiple.OrderId = orderId;
				tblProductPurchaseOrderMultiple.ProductId = productId;
				tblProductPurchaseOrderMultiple.Quantity = quantity;
				tblProductPurchaseOrderMultiple.ShippingFirstName = shippingFirstName;
				tblProductPurchaseOrderMultiple.ShippingLastName = shippingLastName;
				tblProductPurchaseOrderMultiple.ShippingAddressLine1 = shippingAddressLine1;
				tblProductPurchaseOrderMultiple.ShippingAddressLine2 = shippingAddressLine2;
				tblProductPurchaseOrderMultiple.ShippingCity = shippingCity;
				tblProductPurchaseOrderMultiple.ShippingAddressState = shippingAddressState;
				tblProductPurchaseOrderMultiple.ShippingAddressCountry = shippingAddressCountry;
				tblProductPurchaseOrderMultiple.ShippingZipCode = shippingZipCode;
				tblProductPurchaseOrderMultiple.ShippingTelephoneNumber = shippingTelephoneNumber;
				tblProductPurchaseOrderMultiple.ShippingTelephoneNumber2 = shippingTelephoneNumber2;
				tblProductPurchaseOrderMultiple.ShippingEmailAddress = shippingEmailAddress;
			
			return TblProductPurchaseOrderMultiple.UpdateTblProductPurchaseOrderMultiple(tblProductPurchaseOrderMultiple);
		}

		/************************************************************************************
                         -- DELETE METHODS --
        *************************************************************************************/
        /************************* Architecure note:**********************************
        We have used the employeeId parameter as SqlInt32, to bind the delete method with object data source and view control directly.
        ****************************************************************************/
		[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Update, true)]
        public static  bool DeleteTblProductPurchaseOrderMultiple
		(
			Int32 multipleId
		)
		{
			//Validate Input
			if(multipleId <= GetMultipleIdMinValue)
				throw (new ArgumentOutOfRangeException("multipleId"));
				
			// Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
			AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
			AddParameterToSqlCmd(sqlCmd, "@MultipleId",SqlDbType.Int, 0, ParameterDirection.Input, multipleId);
			SetCommandType(sqlCmd,CommandType.StoredProcedure,SPR_TBLPRODUCTPURCHASEORDERMULTIPLE_DELETETBLPRODUCTPURCHASEORDERMULTIPLE);
			ExecuteScalarCmd(sqlCmd);
			int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
			return (returnValue == 0 ? false : true);
			
		}
		
		/// <summary>
        /// Deletes a set of employees from the database.
        /// </summary>
		public static bool DeleteTblProductPurchaseOrderMultipleList( System.Collections.Generic.List<Int32>  multipleIdListToDelete)
		{
			//Validate Input
			foreach (Int32 multipleId in multipleIdListToDelete)
			    if(multipleId <= GetMultipleIdMinValue)
					throw (new ArgumentOutOfRangeException("multipleId"));
			
			//performing deletion operation //

            string xmlString = FormatXMLForIdArray(multipleIdListToDelete);
			
			// Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
			AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            AddParameterToSqlCmd(sqlCmd, "@MultipleIdList", SqlDbType.Xml, xmlString.ToString().Length, ParameterDirection.Input, xmlString.ToString());
			SetCommandType(sqlCmd,CommandType.StoredProcedure,SPR_TBLPRODUCTPURCHASEORDERMULTIPLE_DELETETBLPRODUCTPURCHASEORDERMULTIPLELIST);
			ExecuteScalarCmd(sqlCmd);
			int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
			return (returnValue == multipleIdListToDelete.Count ? true : false);
		}
		
		/************************************************************************************
                                 -- GET BY PRIMARY METHODS --
        *************************************************************************************/
        /************************* Architecure note:**********************************
        Retrives an Employee from database, based on it's primary key.
        To view or update an employee, everytime we must have to use this type of 'get' method, 
        since we don't have direct access to the Primary key value for assigning value.
        We have used the employeeId parameter as SqlInt32, to bind the delete method with object data source and view control directly.
        /*****************************************************************************/
		[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
		public static TblProductPurchaseOrderMultiple GetTblProductPurchaseOrderMultipleByMultipleId(Int32 multipleId)
		{
			if(multipleId <= GetMultipleIdMinValue)
					throw (new ArgumentOutOfRangeException("multipleId"));
				
		 	// Execute SQL Command
			SqlCommand sqlCmd = new SqlCommand();
			AddParameterToSqlCmd(sqlCmd, "@MultipleId",SqlDbType.Int, 0, ParameterDirection.Input, multipleId);
			SetCommandType(sqlCmd,CommandType.StoredProcedure,SPR_TBLPRODUCTPURCHASEORDERMULTIPLE_GETTBLPRODUCTPURCHASEORDERMULTIPLEBYMULTIPLEID);
			GenerateCollectionFromReader test = new GenerateCollectionFromReader(GenerateTblProductPurchaseOrderMultipleCollectionFromReader);
            CustomCollection<TblProductPurchaseOrderMultiple> objCollection = ((CustomCollection<TblProductPurchaseOrderMultiple>)ExecuteReaderCmd(sqlCmd, test));

            if (objCollection.Count > 0)
                return objCollection[0];
            else
                return null;
		}
		
		/************************************************************************************
                         -- GET BY FOREIGN KEY METHODS --
        *************************************************************************************/
		
		/************************************************************************************
                 -- GET ALL METHODS --
        *************************************************************************************/
		[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
        public static CustomCollection<TblProductPurchaseOrderMultiple> GetAllTblProductPurchaseOrderMultiple()
		{
		
		 	// Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            SetCommandType(sqlCmd,CommandType.StoredProcedure,SPR_TBLPRODUCTPURCHASEORDERMULTIPLE_GETALLTBLPRODUCTPURCHASEORDERMULTIPLE);
            GenerateCollectionFromReader test = new GenerateCollectionFromReader(GenerateTblProductPurchaseOrderMultipleCollectionFromReader);
            CustomCollection<TblProductPurchaseOrderMultiple> objCollection = ((CustomCollection<TblProductPurchaseOrderMultiple>)ExecuteReaderCmd(sqlCmd, test));

            return objCollection;
		}
		
		[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
        public static CustomCollection<TblProductPurchaseOrderMultiple> GetAllTblProductPurchaseOrderMultiplePaged(String orderBy, Int32 startRowIndex, Int32 maximumRows)
        {
            //Validate Input
            if (orderBy == "")
                orderBy = "MultipleId";

            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@orderby", SqlDbType.VarChar, 50, ParameterDirection.Input, orderBy);
            AddParameterToSqlCmd(sqlCmd, "@startrow", SqlDbType.Int, 0, ParameterDirection.Input, startRowIndex);
            AddParameterToSqlCmd(sqlCmd, "@pagesize", SqlDbType.Int, 0, ParameterDirection.Input, maximumRows);

            SetCommandType(sqlCmd,CommandType.StoredProcedure,SPR_TBLPRODUCTPURCHASEORDERMULTIPLE_GETALLTBLPRODUCTPURCHASEORDERMULTIPLEPAGED);

            GenerateCollectionFromReader test = new GenerateCollectionFromReader(GenerateTblProductPurchaseOrderMultipleCollectionFromReader);
            CustomCollection<TblProductPurchaseOrderMultiple> objCollection = ((CustomCollection<TblProductPurchaseOrderMultiple>)ExecuteReaderCmd(sqlCmd, test));
            return objCollection;
        }
		
		[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
        public static int GetAllTblProductPurchaseOrderMultiplePagedCount(String orderBy, Int32 startRowIndex, Int32 maximumRows)
        {
            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();

            AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            SetCommandType(sqlCmd,CommandType.StoredProcedure,SPR_TBLPRODUCTPURCHASEORDERMULTIPLE_GETALLTBLPRODUCTPURCHASEORDERMULTIPLEPAGEDCOUNT);
            ExecuteScalarCmd(sqlCmd);

            int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
            return returnValue;
        }
		
		#endregion
		#region Employee Instance Methods
		/************************************************************************************
                                    -- SAVE (INSERT/UPDATE) METHODS (INSTANCE) --
        *************************************************************************************/
		/// <summary>
        /// Saves (inserts and updates) an Employee into database.
        /// The insertion occur if the EmployeeId conatins default value.
        /// Otherwises it updates the Employee into the database, based on the primary key value stored in EmployeeId.
        /// This technique ensures an Employee will not be updated without having a valid EmployeeId.
        /// </summary>
		public bool Save()
		{
			if(MultipleId<= GetMultipleIdMinValue)
			{
				Int32 TempId=CreateNewTblProductPurchaseOrderMultiple(this);
				if(TempId>0)
				{
					_multipleId=TempId;
					return true;
				}
				else
				{
					// error occurs
					return false;
				}
			}
			else
			{	//This is a update Command
				return (UpdateTblProductPurchaseOrderMultiple(this));
			}
			
		}
		
		public static Int32 CreateNewTblProductPurchaseOrderMultiple(TblProductPurchaseOrderMultiple newTblProductPurchaseOrderMultiple)
		{
			// validate Parameters
			if (newTblProductPurchaseOrderMultiple == null)
				throw (new ArgumentNullException("newTblProductPurchaseOrderMultiple"));

			// Execute SQL Command
			SqlCommand sqlCmd = new SqlCommand();
			int length = 0;
			AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            
			AddParameterToSqlCmd(sqlCmd, "@OrderId",SqlDbType.Int, 0, ParameterDirection.Input, newTblProductPurchaseOrderMultiple.OrderId);
			AddParameterToSqlCmd(sqlCmd, "@ProductId",SqlDbType.Int, 0, ParameterDirection.Input, newTblProductPurchaseOrderMultiple.ProductId);
			AddParameterToSqlCmd(sqlCmd, "@Quantity",SqlDbType.Int, 0, ParameterDirection.Input, newTblProductPurchaseOrderMultiple.Quantity);
			AddParameterToSqlCmd(sqlCmd, "@ShippingFirstName",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblProductPurchaseOrderMultiple.ShippingFirstName);
			AddParameterToSqlCmd(sqlCmd, "@ShippingLastName",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblProductPurchaseOrderMultiple.ShippingLastName);
			AddParameterToSqlCmd(sqlCmd, "@ShippingAddressLine1",SqlDbType.NVarChar, 4000, ParameterDirection.Input, newTblProductPurchaseOrderMultiple.ShippingAddressLine1);
			AddParameterToSqlCmd(sqlCmd, "@ShippingAddressLine2",SqlDbType.NVarChar, 4000, ParameterDirection.Input, newTblProductPurchaseOrderMultiple.ShippingAddressLine2);
			AddParameterToSqlCmd(sqlCmd, "@ShippingCity",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblProductPurchaseOrderMultiple.ShippingCity);
			AddParameterToSqlCmd(sqlCmd, "@ShippingAddressState",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblProductPurchaseOrderMultiple.ShippingAddressState);
			AddParameterToSqlCmd(sqlCmd, "@ShippingAddressCountry",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblProductPurchaseOrderMultiple.ShippingAddressCountry);
			AddParameterToSqlCmd(sqlCmd, "@ShippingZipCode",SqlDbType.NVarChar, 50, ParameterDirection.Input, newTblProductPurchaseOrderMultiple.ShippingZipCode);
			AddParameterToSqlCmd(sqlCmd, "@ShippingTelephoneNumber",SqlDbType.NVarChar, 50, ParameterDirection.Input, newTblProductPurchaseOrderMultiple.ShippingTelephoneNumber);
			AddParameterToSqlCmd(sqlCmd, "@ShippingTelephoneNumber2",SqlDbType.NVarChar, 50, ParameterDirection.Input, newTblProductPurchaseOrderMultiple.ShippingTelephoneNumber2);
			AddParameterToSqlCmd(sqlCmd, "@ShippingEmailAddress",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblProductPurchaseOrderMultiple.ShippingEmailAddress);
			
			SetCommandType(sqlCmd,CommandType.StoredProcedure,SPR_TBLPRODUCTPURCHASEORDERMULTIPLE_CREATENEWTBLPRODUCTPURCHASEORDERMULTIPLE);
			ExecuteScalarCmd(sqlCmd);
			return (Int32.Parse(sqlCmd.Parameters["@ReturnValue"].Value.ToString()));

		}
		/// <summary>
        /// Updates an TblProductPurchaseOrderMultiple instance to the database.
        /// </summary>
		public static bool UpdateTblProductPurchaseOrderMultiple(TblProductPurchaseOrderMultiple newTblProductPurchaseOrderMultiple)
		{
			// validate Parameters
			if (newTblProductPurchaseOrderMultiple == null)
				throw (new ArgumentNullException("newTblProductPurchaseOrderMultiple"));

			// Execute SQL Command
			SqlCommand sqlCmd = new SqlCommand();
			int length = 0;
			AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            
			AddParameterToSqlCmd(sqlCmd, "@MultipleId",SqlDbType.Int, 0, ParameterDirection.Input, newTblProductPurchaseOrderMultiple.MultipleId);
			AddParameterToSqlCmd(sqlCmd, "@OrderId",SqlDbType.Int, 0, ParameterDirection.Input, newTblProductPurchaseOrderMultiple.OrderId);
			AddParameterToSqlCmd(sqlCmd, "@ProductId",SqlDbType.Int, 0, ParameterDirection.Input, newTblProductPurchaseOrderMultiple.ProductId);
			AddParameterToSqlCmd(sqlCmd, "@Quantity",SqlDbType.Int, 0, ParameterDirection.Input, newTblProductPurchaseOrderMultiple.Quantity);
			AddParameterToSqlCmd(sqlCmd, "@ShippingFirstName",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblProductPurchaseOrderMultiple.ShippingFirstName);
			AddParameterToSqlCmd(sqlCmd, "@ShippingLastName",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblProductPurchaseOrderMultiple.ShippingLastName);
			AddParameterToSqlCmd(sqlCmd, "@ShippingAddressLine1",SqlDbType.NVarChar, 4000, ParameterDirection.Input, newTblProductPurchaseOrderMultiple.ShippingAddressLine1);
			AddParameterToSqlCmd(sqlCmd, "@ShippingAddressLine2",SqlDbType.NVarChar, 4000, ParameterDirection.Input, newTblProductPurchaseOrderMultiple.ShippingAddressLine2);
			AddParameterToSqlCmd(sqlCmd, "@ShippingCity",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblProductPurchaseOrderMultiple.ShippingCity);
			AddParameterToSqlCmd(sqlCmd, "@ShippingAddressState",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblProductPurchaseOrderMultiple.ShippingAddressState);
			AddParameterToSqlCmd(sqlCmd, "@ShippingAddressCountry",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblProductPurchaseOrderMultiple.ShippingAddressCountry);
			AddParameterToSqlCmd(sqlCmd, "@ShippingZipCode",SqlDbType.NVarChar, 50, ParameterDirection.Input, newTblProductPurchaseOrderMultiple.ShippingZipCode);
			AddParameterToSqlCmd(sqlCmd, "@ShippingTelephoneNumber",SqlDbType.NVarChar, 50, ParameterDirection.Input, newTblProductPurchaseOrderMultiple.ShippingTelephoneNumber);
			AddParameterToSqlCmd(sqlCmd, "@ShippingTelephoneNumber2",SqlDbType.NVarChar, 50, ParameterDirection.Input, newTblProductPurchaseOrderMultiple.ShippingTelephoneNumber2);
			AddParameterToSqlCmd(sqlCmd, "@ShippingEmailAddress",SqlDbType.NVarChar, 500, ParameterDirection.Input, newTblProductPurchaseOrderMultiple.ShippingEmailAddress);
			
			SetCommandType(sqlCmd,CommandType.StoredProcedure,SPR_TBLPRODUCTPURCHASEORDERMULTIPLE_UPDATETBLPRODUCTPURCHASEORDERMULTIPLE);
            ExecuteScalarCmd(sqlCmd);
			int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
			return (returnValue == 0 ? false : true);
		}
		#endregion
		
		#region TblProductPurchaseOrderMultiple Related Collections
		/// <summary>
        /// Creates and returns a strongly typed collection of Employee custom entity. 
        /// The colelction is created through iterating on the IdataReader object which contains Employee information, as a set of records, similar to tabular format.
        /// </summary>
		public static CollectionBase  GenerateTblProductPurchaseOrderMultipleCollectionFromReader(IDataReader returnData) 
		{
			
			//creating the instance of Employee collection
			CustomCollection<TblProductPurchaseOrderMultiple> colTblProductPurchaseOrderMultiple = new CustomCollection<TblProductPurchaseOrderMultiple>();
			
			/************************* Architecure note:**********************************
             * Below code includes the null value functionality to retieve the data which has nill value in database end.
             * Design consideration:
             * Besides general data fields, special care should be taken for primary keys, to assign '0'/defaultvalue, rather passing 'Null' value in constructor parameter.
             * Although we are considering sqldb tyoe data for the current data container, but while retireving data from database end, through datareader object, we need to cast data reader objects using .net primitive data type, 
             * rather using sqldb type to cast, since data reader objects don't support sql db type to be casted.
             *****************************************************************************/

            //Iterating thriugh the data reader, to generate Employee collection.

			//getting the Employee collection by iterating thru the data reader
			while (returnData.Read()) 
			{
				//passing the TblProductPurchaseOrderMultiple constructor parameters from the current instance of data reader fields.
				TblProductPurchaseOrderMultiple newTblProductPurchaseOrderMultiple = new TblProductPurchaseOrderMultiple
				(
					returnData["MultipleId"]== System.DBNull.Value ? GetMultipleIdMinValue : (Int32 ) returnData["MultipleId"],
					returnData["OrderId"]== System.DBNull.Value ? 0: (Int32 ) returnData["OrderId"],
					returnData["ProductId"]== System.DBNull.Value ? 0: (Int32 ) returnData["ProductId"],
					returnData["Quantity"]== System.DBNull.Value ? 0: (Int32 ) returnData["Quantity"],
					returnData["ShippingFirstName"]== System.DBNull.Value ? string.Empty: (String ) returnData["ShippingFirstName"],
					returnData["ShippingLastName"]== System.DBNull.Value ? string.Empty: (String ) returnData["ShippingLastName"],
					returnData["ShippingAddressLine1"]== System.DBNull.Value ? string.Empty: (String ) returnData["ShippingAddressLine1"],
					returnData["ShippingAddressLine2"]== System.DBNull.Value ? string.Empty: (String ) returnData["ShippingAddressLine2"],
					returnData["ShippingCity"]== System.DBNull.Value ? string.Empty: (String ) returnData["ShippingCity"],
					returnData["ShippingAddressState"]== System.DBNull.Value ? string.Empty: (String ) returnData["ShippingAddressState"],
					returnData["ShippingAddressCountry"]== System.DBNull.Value ? string.Empty: (String ) returnData["ShippingAddressCountry"],
					returnData["ShippingZipCode"]== System.DBNull.Value ? string.Empty: (String ) returnData["ShippingZipCode"],
					returnData["ShippingTelephoneNumber"]== System.DBNull.Value ? string.Empty: (String ) returnData["ShippingTelephoneNumber"],
					returnData["ShippingTelephoneNumber2"]== System.DBNull.Value ? string.Empty: (String ) returnData["ShippingTelephoneNumber2"],
					returnData["ShippingEmailAddress"]== System.DBNull.Value ? string.Empty: (String ) returnData["ShippingEmailAddress"]

				);
				//adding the Employee to the collection
				colTblProductPurchaseOrderMultiple.Add(newTblProductPurchaseOrderMultiple);
			}
			
			//returns the collection of Companys 
			return (colTblProductPurchaseOrderMultiple);
		}
		
		#endregion
		#region Constants and Default Values
		
		public static Int32 GetMultipleIdMinValue
		{
			get
			{
				return 0;
			}
		}
		
		//create method related contants
			internal const string SPR_TBLPRODUCTPURCHASEORDERMULTIPLE_CREATENEWTBLPRODUCTPURCHASEORDERMULTIPLE="spr_TblProductPurchaseOrderMultiple_CreateNewTblProductPurchaseOrderMultiple";
			internal const string SPR_TBLPRODUCTPURCHASEORDERMULTIPLE_UPDATETBLPRODUCTPURCHASEORDERMULTIPLE="spr_TblProductPurchaseOrderMultiple_UpdateTblProductPurchaseOrderMultiple";
			internal const string SPR_TBLPRODUCTPURCHASEORDERMULTIPLE_DELETETBLPRODUCTPURCHASEORDERMULTIPLE="spr_TblProductPurchaseOrderMultiple_DeleteTblProductPurchaseOrderMultiple";
			internal const string SPR_TBLPRODUCTPURCHASEORDERMULTIPLE_DELETETBLPRODUCTPURCHASEORDERMULTIPLELIST="spr_TblProductPurchaseOrderMultiple_DeleteTblProductPurchaseOrderMultipleList";
			internal const string SPR_TBLPRODUCTPURCHASEORDERMULTIPLE_GETTBLPRODUCTPURCHASEORDERMULTIPLEBYMULTIPLEID="spr_TblProductPurchaseOrderMultiple_GetTblProductPurchaseOrderMultipleByMultipleId";
			internal const string SPR_TBLPRODUCTPURCHASEORDERMULTIPLE_GETALLTBLPRODUCTPURCHASEORDERMULTIPLE="spr_TblProductPurchaseOrderMultiple_GetAllTblProductPurchaseOrderMultiple";
			internal const string SPR_TBLPRODUCTPURCHASEORDERMULTIPLE_GETALLTBLPRODUCTPURCHASEORDERMULTIPLEPAGED="spr_TblProductPurchaseOrderMultiple_GetAllTblProductPurchaseOrderMultiplePaged";
			internal const string SPR_TBLPRODUCTPURCHASEORDERMULTIPLE_GETALLTBLPRODUCTPURCHASEORDERMULTIPLEPAGEDCOUNT="spr_TblProductPurchaseOrderMultiple_GetAllTblProductPurchaseOrderMultiplePagedCount";
		
		#endregion
	}
}	
